#!/bin/sh

jarname="sparkdriver.jar"
dir="/Users/alex/IdeaProjects/sparkclassification"
cd $dir && sbt assembly
if [ $? == 0 ];then
	mime="${dir}/target/scala-2.12/${jarname}"

	remotehost="192.168.200.25"
	username="zzd" 

	selfdir="$(cd "$(dirname "$0")" && pwd)"
	jardir=${mime%/*}


	localdir="/home/zzd/program/spark/"
	target="${localdir}${jarname}" #要执行的hadoop jar路径及文件名
	nextscrpit="/home/${username}/shell/sparkdriver.sh"

	echo "copying hadoopjar to $remotehost"
	sc="scp -i ~/.ssh/slabmaster ${mime} ${username}@${remotehost}:${target}"
	eval $sc
	if [ $? == 0 ]; then
		echo "successfully copy to ${remotehost}"
		echo "execute ... remote script "
		ssh -i ~/.ssh/slabmaster ${username}@${remotehost} "$nextscrpit"
	fi
fi
